package com.smh.mianshi;

import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.MutablePropertySources;
import org.springframework.core.env.PropertySource;

import java.util.HashMap;
import java.util.Map;

@SpringBootApplication
public class MianshiApplication {

    public static void main(String[] args) {
//        ConfigurableApplicationContext context1 = new SpringApplication(MianshiApplication.class).run(args);
        ConfigurableApplicationContext context = SpringApplication.run(MianshiApplication.class, args);
//        ConfigurableEnvironment environment = context.getEnvironment();
//        String applicationName = environment.getProperty("applicationName");
//        System.out.println(applicationName);

        //AnnotationConfigServletWebServerApplicationContext ,context最终的容器类型
//        System.out.println(context);

        //beanfactory 是bean容器的跟接口,提供bean对象的创建和配置,依赖注入

        //记住DefaultListableBeanFactory 和 ApplicationConfigServletWebServerApplicationContext是常见的两个实现
       /* ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
        MianshiApplication bean = beanFactory.getBean(MianshiApplication.class);
        System.out.println(bean);*/

        //beandefinition接口是对bean的描述，包括bean的class，scope，lazy，init等
        //通过bean注解生成的bean对象,最后是ConfigurationClassBeanDefinition,其他的是ScannedGenericBeanDefinition,但是他们都实现了BeanDefinition
       /* ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
        BeanDefinition uc = beanFactory.getBeanDefinition("user-com");
        BeanDefinition ub = beanFactory.getBeanDefinition("user-bean");
        System.out.println(uc.getClass());
        System.out.println(ub.getClass());*/

//        System.out.println(context.getBean("teacher"));


    }

}
